<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>Jsonp (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">net.Jsonp</span>
        <span>Extends</span>
        <span class="fn-name">
          
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Creates a new cross domain channel that sends data to the specified
host URL. By default, if no reply arrives within 5s, the channel
assumes the call failed to complete successfully.


  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_net_jsonp.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/net/jsonp.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td>goog.net.Jsonp</td><td></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
</table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.net.Jsonp(<span><span class="arg">uri</span>,&nbsp;<span class="arg">opt_callbackParamName</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">uri</span>
        : <span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The Uri of the server side code that receives
    data posted through this channel (e.g.,
    "<a href="http://maps.google.com/maps/geo">http://maps.google.com/maps/geo</a>").</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_callbackParamName</span>
        : <span class="type">string=</span>
        <div class="entryOverview">The parameter name that is used to
    specify the callback. Defaults to "callback".</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_net_Jsonp.html">
              goog.net.Jsonp
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.cancel"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">cancel<span class="args">(<span class="arg">request</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Cancels a given request. The request must be exactly the object returned by
the send method.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">request</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The request object returned by the send method.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line213">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.getRequestTimeout"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getRequestTimeout<span class="args">()</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Returns the current timeout value, in milliseconds.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            The timeout value.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line130">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.send"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">send<span class="args">(<span class="arg">opt_payload</span>,&nbsp;<span class="arg">opt_replyCallback</span>,&nbsp;<span class="arg">opt_errorCallback</span>,&nbsp;<span class="arg">opt_callbackParamValue</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
      </div>


     <div class="entryOverview">
       Sends the given payload to the URL specified at the construction
time. The reply is delivered to the given replyCallback. If the
errorCallback is specified and the reply does not arrive within the
timeout period set on this channel, the errorCallback is invoked
with the original payload.

If no reply callback is specified, then the response is expected to
consist of calls to globally registered functions. No &amp;callback=
URL parameter will be sent in the request, and the script element
will be cleaned up after the timeout.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">opt_payload</span>
        : <span class="type">Object=</span>
        <div class="entryOverview">Name-value pairs.  If given, these will be
    added as parameters to the supplied URI as GET parameters to the
    given server URI.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_replyCallback</span>
        : <span class="type">Function=</span>
        <div class="entryOverview">A function expecting one
    argument, called when the reply arrives, with the response data.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_errorCallback</span>
        : <span class="type">Function=</span>
        <div class="entryOverview">A function expecting one
    argument, called on timeout, with the payload (if given), otherwise
    null.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_callbackParamValue</span>
        : <span class="type">string=</span>
        <div class="entryOverview">Value to be used as the
    parameter value for the callback parameter (callbackParamName).
    To be used when the value needs to be fixed by the client for a
    particular request, to make use of the cached responses for the request.
    NOTE: If multiple requests are made with the same
    opt_callbackParamValue, only the last call will work whenever the
    response comes back.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&nbsp;
            A request descriptor that may be used to cancel this
    transmission, or null, if the message may not be cancelled.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line169">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.setRequestTimeout"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">setRequestTimeout<span class="args">(<span class="arg">timeout</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Sets the length of time, in milliseconds, this channel is prepared
to wait for for a request to complete. If the call is not competed
within the set time span, it is assumed to have failed. To wait
indefinitely for a request to complete set the timout to a negative
number.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeout</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">The length of time before calls are
interrupted.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line120">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_net_Jsonp.html">
              goog.net.Jsonp
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.net.Jsonp.prototype.callbackParamName_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">callbackParamName_</span>
        : 
     </div>


     <div class="entryOverview">
       This is the callback parameter name that is added to the uri.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line82">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.net.Jsonp.prototype.timeout_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">timeout_</span>
        : 
     </div>


     <div class="entryOverview">
       The length of time, in milliseconds, this channel is prepared
to wait for for a request to complete. The default value is 5 seconds.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line91">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.net.Jsonp.prototype.uri_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">uri_</span>
        : <span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>
     </div>


     <div class="entryOverview">
       The uri_ object will be used to encode the payload that is sent to the
server.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line75">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.addPayloadToUri_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">addPayloadToUri_<span class="args">(<span class="arg">payload</span>,&nbsp;<span class="arg">uri</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>
      </div>


     <div class="entryOverview">
       Returns URL encoded payload. The payload should be a map of name-value
pairs, in the form {"foo": 1, "bar": true, ...}.  If the map is empty,
the URI will be unchanged.

<p>The method uses hasOwnProperty() to assure the properties are on the
object, not on its prototype.

</p>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">payload</span>
        : <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">A map of value name pairs to be encoded.
    A value may be specified as an array, in which case a query parameter
    will be created for each value, e.g.:
    {"foo": [1,2]} will encode to "foo=1&amp;foo=2".</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">uri</span>
        : <span>!</span><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>
        <div class="entryOverview">A Uri object onto which the payload key value pairs
    will be encoded.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span>&nbsp;
            A reference to the Uri sent as a parameter.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line317">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.cleanup_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">cleanup_<span class="args">(<span class="arg">id</span>,&nbsp;<span class="arg">deleteReplyHandler</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Removes the script node and reply handler with the given id.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">id</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The id of the script node to be removed.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">deleteReplyHandler</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
        <div class="entryOverview">If true, delete the reply handler
    instead of setting it to nullFunction (if we know the callback could
    never be called again).</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line285">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.newErrorHandler_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">newErrorHandler_<span class="args">(<span class="arg">id</span>,&nbsp;<span class="arg">payload</span>,&nbsp;<span class="arg">opt_errorCallback</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
      </div>


     <div class="entryOverview">
       Creates a timeout callback that calls the given timeoutCallback with the
original payload.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">id</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The id of the script node.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">payload</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
        <div class="entryOverview">The payload that was sent to the server.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_errorCallback</span>
        : <span class="type">Function=</span>
        <div class="entryOverview">The function called on timeout.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>&nbsp;
            A zero argument function that handles callback duties.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line235">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.newReplyHandler_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">newReplyHandler_<span class="args">(<span class="arg">id</span>,&nbsp;<span class="arg">replyCallback</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
      </div>


     <div class="entryOverview">
       Creates a reply callback that calls the given replyCallback with data
returned by the server.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">id</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The id of the script node.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">replyCallback</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>
        <div class="entryOverview">The function called on reply.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span>&nbsp;
            A reply callback function.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line261">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.net.Jsonp.CALLBACKS"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">CALLBACKS</span>
        : 
     </div>


     <div class="entryOverview">
       The name of the property of goog.global under which the callback is
stored.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line99">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.net.Jsonp.scriptCounter_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">scriptCounter_</span>
        : 
     </div>


     <div class="entryOverview">
       Used to generate unique callback IDs. The counter must be global because
all channels share a common callback object.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_net_jsonp.js.source.html#line107">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package net</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="net.Jsonp"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
